package com.leo.foodmaster.admin.customer.service.impl;

import org.springframework.stereotype.Service;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.leo.foodmaster.admin.customer.dto.CustomerDeliveryAreaDTO;
import com.leo.foodmaster.admin.customer.entity.CustomerDeliveryAreaEntity;
import com.leo.foodmaster.admin.customer.mapper.CustomerDeliveryAreaMapper;
import com.leo.foodmaster.admin.customer.service.ICustomerDeliveryAreaService;
import lombok.AllArgsConstructor;

/**
 * 客户配送区域
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2021-11-20
 */
@Service
@AllArgsConstructor
public class ICustomerDeliveryAreaServiceImpl extends ServiceImpl<CustomerDeliveryAreaMapper, CustomerDeliveryAreaEntity> implements ICustomerDeliveryAreaService {

	private final CustomerDeliveryAreaMapper customerDeliveryAreaMapper;
	@Override
	public IPage<CustomerDeliveryAreaEntity> page(IPage<CustomerDeliveryAreaDTO> page, CustomerDeliveryAreaDTO customerDeliveryAreadto) {
			CustomerDeliveryAreaEntity customerDeliveryAreaentity=new CustomerDeliveryAreaEntity();
		BeanUtil.copyProperties(customerDeliveryAreadto,customerDeliveryAreaentity);
		LambdaQueryWrapper<CustomerDeliveryAreaEntity> eq = Wrappers.lambdaQuery(customerDeliveryAreaentity);
		return customerDeliveryAreaMapper.selectPage(new Page<>(page.getCurrent(),page.getSize()), eq);
	}

	@Override
	public IPage<CustomerDeliveryAreaDTO> pageList(IPage<CustomerDeliveryAreaDTO> page,CustomerDeliveryAreaDTO customerDeliveryAreaDTO) {

		return customerDeliveryAreaMapper.pageList(page,customerDeliveryAreaDTO);
	}}
